package com.deneme.ozveri.admin;


import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.deneme.ozveri.application.OzveriMenuApplicationObject;
import com.deneme.ozveri.objects.MenuItem;
import com.deneme.ozverimenu.R;

import android.app.Activity;
import android.content.ClipData.Item;
import android.os.Bundle;
import android.util.Log;

public class AdminActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.admin);
		super.onCreate(savedInstanceState);


		JSONObject dummyData = new JSONObject();
		try {
			dummyData.put("v", 1); //version
			dummyData.put("c", 1); //code
			dummyData.put("tm", 1); //time

			//init menu

			JSONArray dummyMenu = new JSONArray();

			JSONObject dummyMenuItem = new JSONObject();
			dummyMenuItem.put("id", 115);
			dummyMenuItem.put("nm", "CORBALARS");

			JSONArray dummySubItems = new JSONArray();

			JSONObject dummySubItem = new JSONObject();
			dummySubItem.put("nm", "GUNUN CORBASI");
			dummySubItem.put("id", 1151);

			JSONArray dummyItems = new JSONArray();

			JSONObject dummyItem = new JSONObject();
			dummyItem.put("id", 11511);
			dummyItem.put("nm", "EZOGELIN");
			dummyItem.put("sdesc", "ailesnizin ezogelin corbasi");
			dummyItem.put("desc", "Soğanı incecik doğrayın; derin bir tencereye tereyağı ile birlikte koyun. Altın sarısı renk alana kadar kavurun.Salçayı katın. Güzel kokusu gelene kadar 1-2 dakika kavurun. Et suyunu veya suyu ilave edin. Yıkanıp süzülmüş mercimeği katın, bir taşım kaynatın. Kaynar suya ayıklanmış bulguru, pul biberi ve tuzu ilave edin. Arada sırada karıştırarak mercimek yumuşayana kadar pişirin. Ezogelin Çorbasının üzerine kuru nane serpiştirdikten sonra çorbayı servis yapın. Sitemizdeki diğer çorba tariflerimize de göz atabilirsiniz.");
			dummyItem.put("prc", 450);
			
			JSONArray extras = new JSONArray();
			JSONObject extra1 = new JSONObject();
			extra1.put("id", 15111);
			extra1.put("nm", "double");
			extra1.put("gid", 1);
			extra1.put("gnm", "Buyukluk");
			extra1.put("prc", 150);
			extra1.put("typ", 0);
			
			JSONObject extra2 = new JSONObject();
			extra2.put("id", 15112);
			extra2.put("nm", "bir bucuk");
			extra2.put("gid", 1);
			extra2.put("gnm", "Buyukluk");
			extra2.put("prc", 100);
			extra2.put("typ", 0);
			
			JSONObject extra3 = new JSONObject();
			extra3.put("id", 15113);
			extra3.put("nm", "Acili");
			extra3.put("gid", 0);
			extra3.put("gnm", "");
			extra3.put("prc", 0);
			extra3.put("typ", 0);
			
			JSONObject extra4 = new JSONObject();
			extra4.put("id", 15114);
			extra4.put("nm", "Kasarli");
			extra4.put("gid", 0);
			extra4.put("gnm", "");
			extra4.put("prc", 0);
			extra4.put("typ", 0);
			
			JSONObject extra5 = new JSONObject();
			extra5.put("id", 15115);
			extra5.put("nm", "Ekmek");
			extra5.put("gid", 0);
			extra5.put("gnm", "");
			extra5.put("prc", 50);
			extra5.put("typ", 1);
			
			extras.put(extra1);
			extras.put(extra2);
			extras.put(extra3);
			extras.put(extra4);
			extras.put(extra5);
			
			dummyItem.put("ext", extras);


			JSONObject dummyItem2 = new JSONObject();
			dummyItem2.put("id", 11512);
			dummyItem2.put("nm", "DOMATES CORBASI");
			dummyItem2.put("sdesc", "ailesnizin domates corbasi (benan yapmadi zehirsiz)");
			dummyItem2.put("desc", "ailesnizin domates corbasi (benan yapmadi zehirsiz)");
			dummyItem2.put("prc", 400);


			dummyItems.put(dummyItem);
			dummyItems.put(dummyItem2);

			dummySubItem.put("itm", dummyItems);

			dummySubItems.put(dummySubItem);

			dummyMenuItem.put("sub", dummySubItems);

			dummyMenu.put(dummyMenuItem);

			dummyData.put("menu", dummyMenu);



			Log.w("menuJSON", dummyData.toString());

			((OzveriMenuApplicationObject)getApplication()).dh.addNewMainMenu(dummyMenuItem);

			ArrayList<MenuItem> items = ((OzveriMenuApplicationObject)getApplication()).dh.getMainMenuItems();

			Log.w("items", items.toString());








		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


	}

}
